package cn.xopencode.appletweb.controller.record.kvtransformer;


import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.rpc.kvtransformer.dto.KvTransformerRecordCreateDTO;
import cn.xopencode.recordservice.rpc.kvtransformer.dto.KvTransformerRecordPageDTO;
import cn.xopencode.recordservice.rpc.kvtransformer.dto.KvTransformerRecordUpdateDTO;
import cn.xopencode.recordservice.rpc.kvtransformer.vo.KvTransformerRecordEmpRelVO;
import cn.xopencode.recordservice.rpc.kvtransformer.vo.KvTransformerRecordPageVO;
import cn.xopencode.recordservice.rpc.kvtransformer.vo.KvTransformerRecordUpdateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(tags = "10KV变压器巡检记录 API")
@RestController
@RequestMapping("/kvtransformer")
@Validated
public class KvTransformerRecordController {

    /**
     * 根据查询条件 分页获取所有的10KV变压器巡检记录
     * @param pageDTO
     * @return
     */
    @PostMapping("/getAllByQuery")
    @ApiOperation("根据查询条件分页获取所有的10KV变压器巡检记录")
    public CommonResult<PageResult<KvTransformerRecordPageVO>> getPageKvTransformerRecord(KvTransformerRecordPageDTO pageDTO){
        PageResult<KvTransformerRecordPageVO> result = new PageResult<>();
        ArrayList<KvTransformerRecordPageVO> list = new ArrayList<>();

        KvTransformerRecordPageVO vo = new KvTransformerRecordPageVO();
        vo.setInspectionTime(new Date());
        vo.setEmpRels("张三、李四");
        list.add(vo);

        KvTransformerRecordPageVO vo2 = new KvTransformerRecordPageVO();
        vo2.setInspectionTime(new Date());
        vo2.setEmpRels("王五");
        list.add(vo2);
        result.setList(list);
        return CommonResult.success(result);

    }

    /**
     * 新增 10KV变压器巡检记录
     * @param transformerDTO
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("新增 10KV变压器巡检记录")
    public CommonResult<Integer> createKvTransformerRecord(@Valid KvTransformerRecordCreateDTO transformerDTO){
        return CommonResult.success(1);
    }

    /**
     * 更新 10KV变压器巡检记录
     * @param transformerDTO
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("更新 10KV变压器巡检记录")
    public CommonResult<Integer> updateKvTransformerRecord(@Valid KvTransformerRecordUpdateDTO transformerDTO){
        return CommonResult.success(1);
    }

    /**
     * 根据id获取10KV变压器巡检记录详细
     * @param transformerId
     * @return
     */
    @GetMapping("/getById")
    @ApiOperation("根据id获取10KV变压器巡检记录详细")
    public CommonResult<KvTransformerRecordUpdateVO> getKvTransformerRecordById(String transformerId ){
        KvTransformerRecordUpdateVO vo = new KvTransformerRecordUpdateVO();
        vo.setId("123456");
        vo.setInspectionTime(new Date());
        vo.setOilLevel(1.2);
        vo.setTransformerTemperature(56.32);
        vo.setErrorSound(false);
        vo.setSeepage(false);
        vo.setHighPressureTemperature(54.89);
        vo.setLowPressureTemperature(45.3);
        vo.setGas(true);
        vo.setChangeColor(false);

        List<KvTransformerRecordEmpRelVO> list = new ArrayList<>();
        KvTransformerRecordEmpRelVO relVO = new KvTransformerRecordEmpRelVO();
        relVO.setId("11");
        relVO.setEmpId("111");
        relVO.setRecordId("123456");
        KvTransformerRecordEmpRelVO relVO2 = new KvTransformerRecordEmpRelVO();
        relVO2.setId("22");
        relVO2.setEmpId("222");
        relVO2.setRecordId("123456");
        list.add(relVO);
        list.add(relVO2);

        vo.setEmpList(list);
        return CommonResult.success(vo);
    }

}
